import Vue from 'vue'
import Router from 'vue-router'

Vue.use(Router)

/* Layout */
import Layout from '@/layout'

export const constantRoutes = [{
		path: '/login',
		component: () => import('@/views/login/index'),
		hidden: true
	},

	{
		path: '/404',
		component: () => import('@/views/404'),
		hidden: true
	},
	{
		path: '/',
		component: Layout,
		redirect: '/carousel',
		children: [{
			path: 'carousel',
			name: 'carousel',
			component: () => import('@/views/coupon/index'),
			meta: {
				title: '轮播图',
				icon: 'el-icon-picture-outline'
			}
		}]
	},
	{
		path: '/user',
		component: Layout,
		children: [{
				path: 'user',
				name: 'User',
				component: () => import('@/views/dashboard/index'),
				meta: {
					title: '用户',
					icon: 'el-icon-user'
				}
			},
			{
				path: 'userlog',
				name: 'userlog',
				component: () => import('@/views/userlog/index'),
				meta: {
					title: '用户日志',
					icon: 'form'
				},
				hidden: true,
			},
			{
				path: 'userlogs',
				name: 'userlogs',
				component: () => import('@/views/userlogs/index'),
				meta: {
					title: '所有日志',
					icon: 'form'
				},
				hidden: true,
			}
		]
	},
	{
		path: '/city',
		component: Layout,
		children: [{
				path: 'city',
				name: 'city',
				component: () => import('@/views/city/index'),
				meta: {
					title: '城市列表',
					icon: 'el-icon-location-outline'
				}
			},
			{
				path: 'market',
				name: 'market',
				component: () => import('@/views/market/index'),
				meta: {
					title: '服务',
					icon: 'form'
				},
				hidden: true,
			}
		]
	},
	{
		path: '/viporder',
		component: Layout,
		children: [{
			path: 'viporder',
			name: 'viporder',
			component: () => import('@/views/viporder/index'),
			meta: {
				title: '充值记录',
				icon: 'el-icon-wallet'
			}
		}]
	},
	{
		path: '/copywriting',
		component: Layout,
		children: [{
			path: 'copywriting',
			name: 'copywriting',
			component: () => import('@/views/copywriting/index'),
			meta: {
				title: '文案',
				icon: 'el-icon-tickets'
			}
		}]
	},
	{
		path: '/typelist',
		component: Layout,
		children: [{
			path: 'typelist',
			name: 'typelist',
			component: () => import('@/views/cjwt/index'),
			meta: {
				title: '文案分类',
				icon: 'el-icon-document-copy'
			}
		}]
	},
	// {
	//   path: '/vippackage',
	//   component: Layout,
	//   children: [{
	//     path: 'vippackage',
	//     name: 'vippackage',
	//     component: () => import('@/views/vippackage/index'),
	//     meta: {
	//       title: 'vip套餐列表',
	//       icon: 'form'
	//     }
	//   }]
	// },
	{
		path: '/wholesale',
		component: Layout,
		children: [{
			path: 'wholesale',
			name: 'wholesale',
			component: () => import('@/views/wholesale/index'),
			meta: {
				title: '批发',
				icon: 'el-icon-folder-opened'
			}
		}]
	},
	{
		path: '/consumables',
		component: Layout,
		children: [{
			path: 'consumables',
			name: 'consumables',
			component: () => import('@/views/consumables/index'),
			meta: {
				title: '耗材',
				icon: 'el-icon-folder'
			}
		}]
	}, {
		path: '/	',
		component: Layout,
		children: [{
			path: 'consumablestype',
			name: 'consumablestype',
			component: () => import('@/views/consumablestype/index'),
			meta: {
				title: '耗材分类',
				icon: 'el-icon-folder-remove'
			}
		}]
	},

	{
		path: '*',
		redirect: '/404',
		hidden: true
	},
	{
		path: '/storelist',
		component: Layout,
		children: [{
			path: 'storelist',
			name: 'storelist',
			component: () => import('@/views/storelist/index'),
			meta: {
				title: '门店列表',
				icon: 'el-icon-house'
			}
		}]
	},
	{
		path: '/storestaff',
		component: Layout,
		children: [{
			path: 'storestaff',
			name: 'storestaff',
			component: () => import('@/views/storestaff/index'),
			meta: {
				title: '门店员工',
				icon: 'el-icon-user'
			}
		}]
	},
	{
		path: '/packagelist',
		component: Layout,
		children: [{
			path: 'packagelist',
			name: 'packagelist',
			component: () => import('@/views/package/index'),
			meta: {
				title: 'vip套餐列表',
				icon: 'el-icon-bank-card'
			}
		}]
	},
	{
		path: '/logDataList',
		component: Layout,
		children: [{
			path: 'logDataList',
			name: 'logDataList',
			component: () => import('@/views/logData/index'),
			meta: {
				title: '操作日志',
				icon: 'el-icon-reading'
			}
		}]
	},
	{
		path: '/recommend_plan',
		component: Layout,
		children: [{
			path: 'recommend_plan',
			name: 'recommend_plan',
			component: () => import('@/views/recommend_plan/index'),
			meta: {
				title: '推荐方案',
				icon: 'el-icon-tickets'
			}
		}]
	},
	{
		path: '/recommend_fruit',
		component: Layout,
		children: [{
			path: 'recommend_fruit',
			name: 'recommend_fruit',
			component: () => import('@/views/recommend_fruit/index'),
			meta: {
				title: '推荐水果',
				icon: 'el-icon-apple'
			}
		}]
	},
	{
		path: '/forwardSetting',
		component: Layout,
		children: [{
			path: 'forwardSetting',
			name: 'forwardSetting',
			component: () => import('@/views/forwardSetting/index'),
			meta: {
				title: '转发配置',
				icon: 'el-icon-position'
			}
		}]
	},
	{
		path: '/document_function',
		component: Layout,
		children: [{
			path: 'document_function',
			name: 'document_function',
			component: () => import('@/views/document_function/index'),
			meta: {
				title: '文案弹出配置',
				icon: 'el-icon-chat-dot-square'
			}
		}]
	},
	{
		path: '/functionBtnLog',
		component: Layout,
		children: [{
			path: 'functionBtnLog',
			name: 'functionBtnLog',
			component: () => import('@/views/functionBtnLog/index'),
			meta: {
				title: '文案页按钮点击记录',
				icon: 'el-icon-thumb'
			}
		}]
	},
	{
		path: '/quickSale',
		component: Layout,
		children: [{
			path: 'quickSale',
			name: 'quickSale',
			component: () => import('@/views/quickSale/index'),
			meta: {
				title: '快卖管理',
				icon: 'el-icon-thumb'
			}
		}]
	},
]

const createRouter = () => new Router({
	// mode: 'history', // require service support
	scrollBehavior: () => ({
		y: 0
	}),
	routes: constantRoutes
})

const router = createRouter()

// Detail see: https://github.com/vuejs/vue-router/issues/1234#issuecomment-357941465
export function resetRouter() {
	const newRouter = createRouter()
	router.matcher = newRouter.matcher // reset router
}

export default router